package com.wangjiacai.hqlQuery.hql.condition.where;

import com.wangjiacai.hqlQuery.hql.condition.Condition;
import com.wangjiacai.hqlQuery.util.HqlUtil;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target({ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@Condition(condition = Great.GreatCondition.class,column = Great.GreatCondition.class)
public @interface Great {

    String column() default "";

    String hql() default "";

    class GreatCondition implements Condition.Where<Great,Object> , Condition.Column<Great> {
        @Override
        public String where(Great great,String property,String column,Object obj,Object value) {
            return great.hql().equals("")?column+" > :"+property:column+" > ("+ HqlUtil.parseHql(great.hql(),obj)+")";
        }

        @Override
        public String column(Great great, String property) {
            return great.column().equals("")?property:great.column();
        }
    }

}
